package com.teng.mylibrary.ui.adapter

import android.app.Activity
import com.bumptech.glide.Glide
import com.teng.mylibrary.R
import com.teng.mylibrary.base.BaseVBAdapter
import com.teng.mylibrary.base.BaseViewHolder
import com.teng.mylibrary.databinding.ItemPhotoViewBinding

class PhotoViewAdapter(private val activity: Activity, list: ArrayList<String>) :
    BaseVBAdapter<String>(list) {

    override fun getItemView(viewType: Int): Int {
        return R.layout.item_photo_view
    }

    override fun onBindHolder(holder: BaseViewHolder, position: Int) {
        val binding = holder.dataBinding as ItemPhotoViewBinding
        binding.photoView.setOnViewTapListener { _, _, _ -> activity.finish() }
        mList[position].let {
            Glide.with(activity)
                .load(it)
                .into(binding.photoView)
        }
    }
}